# Distributed under the MIT License.
# Copyright (c) 2012-2018 Denis Demidov <dennis.demidov@gmail.com>

#.rst
# FindVexCL
# ---------
#
# Try to find VexCL include dirs and libraries. Use this module by invoking
# find_package with the form::
#
#   find_package(VexCL
#     [REQUIRED]                 # Fail with error if VexCL is not found
#     [COMPONENTS <backends>...] # Find the specified VexCL backends
#     )
#
# The module defines the following :prop_tgt:`IMPORTED` targets::
#
#   VexCL::OpenCL
#   VexCL::Compute
#   VexCL::CUDA
#   VexCL::JIT

include(CMakeFindDependencyMacro)

# Capture the OpenCL copy used in original VexCL build
if(@OpenCL_FOUND@)
    set(OpenCL_INCLUDE_DIR "@OpenCL_INCLUDE_DIR@")
    set(OpenCL_LIBRARY "@OpenCL_LIBRARY@")
    find_package(OpenCL)
endif()


find_package(OpenMP)


# Capture the Boost copy used in original VexCL build (and main setting)
set(Boost_USE_STATIC_LIBS @Boost_USE_STATIC_LIBS@)
if(NOT BOOST_ROOT)
    set(BOOST_ROOT "@BOOST_ROOT@")
endif()

find_package(Boost REQUIRED COMPONENTS
    chrono
    date_time
    filesystem
    program_options
    system
    thread
    unit_test_framework
    )

include("${CMAKE_CURRENT_LIST_DIR}/VexCLBoostTargets.cmake")

if(TARGET VexCL::OpenCL)
    message(STATUS "Found VexCL::OpenCL")
endif()

if(TARGET VexCL::Compute)
    message(STATUS "Found VexCL::Compute")
endif()

if(TARGET VexCL::CUDA)
    message(STATUS "Found VexCL::CUDA")
endif()

if(TARGET VexCL::JIT)
    message(STATUS "Found VexCL::JIT")
endif()

include("${CMAKE_CURRENT_LIST_DIR}/VexCLTools.cmake")
